#ifndef ARPATTACKER_H
#define ARPATTACKER_H

#include <attacker.h>
#include <attackerMessage.h>
#include <attackTargetMessage.h>

#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <signal.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/ip_icmp.h>
#include <linux/if_ether.h>

namespace Model{

#define ETH_HW_ADDR_LEN 6
#define IP_ADDR_LEN 4
#define ARP_FRAME_TYPE 0x0806
#define ETHER_HW_TYPE 1
#define IP_PROTO_TYPE 0x0800
#define OP_ARP_REQUEST 2
#define OP_ARP_QUEST 1
#define DEFAULT_DEVICE "eth0"
  
  typedef struct _arpPacket
  {
    char targ_hw_addr[ETH_HW_ADDR_LEN];
    char src_hw_addr[ETH_HW_ADDR_LEN];
    u_short frame_type;
    u_short hw_type;
    u_short prot_type;
    u_char hw_addr_size;
    u_char prot_addr_size;
    u_short op;
    char sndr_hw_addr[ETH_HW_ADDR_LEN];
    char sndr_ip_addr[IP_ADDR_LEN];
    char rcpt_hw_addr[ETH_HW_ADDR_LEN];
    char rcpt_ip_addr[IP_ADDR_LEN];
    char padding[18];
  }ArpPacket;

  class ArpAttacker : public Attacker
  {
    void getHwAddr(char* buf, char* str);
    void getIpAddr(struct in_addr* in_addr, char* str);
  protected:
    virtual bool ProcessFunction();
    
  public:
    ArpAttacker(std::map<std::string,model *> *models);
    virtual ~ArpAttacker(){}
  };

}

#endif
